/**
 * 
 */
package us.gaaoc.framework.webapp.backingbeans.attorney;

import java.util.Map;

import javax.faces.component.UISelectItem;
import javax.faces.component.html.HtmlSelectOneListbox;
import javax.faces.model.SelectItem;

import us.gaaoc.framework.webapp.backingbeans.BaseBackingBean;
import us.gaaoc.framework.webapp.backingbeans.caseTypes.OCSSCaseType;
import us.gaaoc.framework.webapp.backingbeans.profile.Links;

/**
 * @author Sukahda Tapshalkar
 * Mar 23, 2007
 *
 */
@SuppressWarnings("unchecked")
public class NewFiling extends BaseBackingBean{
	
	/** Generated Serial Version UID */
	private static final long serialVersionUID = 6898722204279452622L;

	/**
	 * Properties
	 */
	
	private HtmlSelectOneListbox  ocssCaseTypeUI;
	
	

	/**
	 * Constructor
	 *
	 */
	public NewFiling() {
		
		this.ocssCaseTypeUI = new HtmlSelectOneListbox();
		OCSSCaseType ocssCaseType = new OCSSCaseType(this.getModelFacade());
		for (Links links : ocssCaseType.getMenu()) {
			SelectItem item = new SelectItem(links.getNavigationRule(), links.getText());
			UISelectItem uiItem = new UISelectItem();
			uiItem.setValue(item);

			this.ocssCaseTypeUI.getChildren().add(uiItem);
		}
	}
	/**
	 * @return the ocssCaseTypeUI
	 */
	public HtmlSelectOneListbox getOcssCaseTypeUI() {
		return ocssCaseTypeUI;
	}

	/**
	 * @param ocssCaseTypeUI the ocssCaseTypeUI to set
	 */
	public void setOcssCaseTypeUI(HtmlSelectOneListbox ocssCaseTypeUI) {
		this.ocssCaseTypeUI = ocssCaseTypeUI;
	}

	public String submitAction() {
		/*
		String navigationString = "";
		if (this.getOcssCaseTypeUI().getValue().equals("establishment"))
			navigationString = "establishment";
		else if (this.getOcssCaseTypeUI().getValue().equals("contempt"))
			navigationString = "contempt";
		else if (this.getOcssCaseTypeUI().getValue().equals("revisionOrModification"))
			navigationString = "revisionOrModification";
		return navigationString;
		*/
		String navigationString = "filingcategoryselected";
		// TODO Determine if there is a better way to pass the external case category selected to the
		// next page
		/**********************************************************************
		 *  External Case Category Codes:
		 * 1 = Establishment, OCSS
		 * 2 = Contempt, OCSS
		 * 3 = Review/Modification, OCSS
		 * 4 = Motion to Redirect, OCSS
		 * 5 = Motion to Transfer, OCSS
		 * 6 = Registration, OCSS
		 * ********************************************************************
		 */
		 
		Map<String, Object> sessionMap = this.getFacesContext().getExternalContext().getSessionMap();
		/*
		if (this.getOcssCaseTypeUI().getValue().equals("establishment")) {    
			//navigationString = "establishment";
			sessionMap.put("externalCaseCategoryCode", 1); // Establishment
		} else if (this.getOcssCaseTypeUI().getValue().equals("contempt")) {
			//navigationString = "contempt";
			sessionMap.put("externalCaseCategoryCode", 2); // Contempt
		} else if (this.getOcssCaseTypeUI().getValue().equals("reviewOrModification")) {
			//navigationString = "revisionOrModification";
			sessionMap.put("externalCaseCategoryCode", 3); // Review/Modification
		} else if (this.getOcssCaseTypeUI().getValue().equals("motionToRedirect")) {
			//navigationString = "motionToRedirect";
			sessionMap.put("externalCaseCategoryCode", 4); // Motion to Redirect
		} else if (this.getOcssCaseTypeUI().getValue().equals("motionToTransfer")) {
			//navigationString = "motionToTransfer";
			sessionMap.put("externalCaseCategoryCode", 5); // Motion to Transfer
		} else if (this.getOcssCaseTypeUI().getValue().equals("registration")) {
			//navigationString = "registration";
			sessionMap.put("externalCaseCategoryCode", 6); // Registration
		}
		*/
		sessionMap.put("externalCaseCategoryCode",Integer.parseInt((String)this.getOcssCaseTypeUI().getValue()));
		return navigationString;
	}
	
	public String back() {

		Map sessionMap = this.getFacesContext().getExternalContext()
				.getSessionMap();
		//String fromPage = (String) sessionMap.get("from");
		
		
			return "attCaseDetailsPage"; 
		
	}
	
}
